package cn.itcast.bos.action.base;

import java.util.List;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;

import com.opensymphony.xwork2.ActionContext;

import cn.itcast.bos.domain.base.Standard;
import cn.itcast.bos.service.base.StandardService;
import cn.itcast.bos.utils.BaseAction;
public class StandardAction extends BaseAction<Standard>{
	//注入service
	@Autowired
	private StandardService standardService;
	
	//增加保存standard
	@Action(value="standard_save",results={@Result(name="success",location="./pages/base/standard.html",type="redirect")})
	public String save(){
		standardService.add(model);
		return SUCCESS;
	}
	

	//分页查询
	@Action(value="standard_pageQuery",results={@Result(name="success",type="json")})
	public String pageQuery(){
		//调用业务层查询
		Pageable pageable = new PageRequest(page-1, rows);
		Page<Standard> page = standardService.findPageData(pageable);
		pushPageDataToValueStack(page);
		return SUCCESS;
	}
	
	//查询所有取派标准
		@Action(value="standard_findAll",results={@Result(name="success",type="json")})
		public String findAll(){
			List<Standard> list = standardService.findAll();
			ActionContext.getContext().getValueStack().push(list);
			return SUCCESS;
		}
}
